package pattern.Singleton_P;

/**
 * Created by dycong on 2017/3/20.
 * TODO 双重检验锁实现的单例模式
 */
public class Singleton_Double_Lock {
    private Singleton_Double_Lock(){}
    private volatile static Singleton_Double_Lock INSTANCE;     //声明为volatile
    public static Singleton_Double_Lock getInstance(){
        if (INSTANCE==null){
            synchronized (Singleton_Double_Lock.class){
                if (INSTANCE==null){
                    INSTANCE=new Singleton_Double_Lock();
                }
            }
        }
        return INSTANCE;
    }

}
